<admintpl file="header" />
<style type="text/css">
    .pic-list li {
        margin-bottom: 5px;
    }
</style>
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li><a href="{:U('Index/index')}">数据管理</a></li>
        <li class="active"><a href="{:U('Index/add',array('id'=>empty($item['id'])?'':$item['id']))}" target="_self">新增数据</a></li>
    </ul>
    <form action="{:U('Index/add_post')}" method="post" class="form-horizontal js-ajax-forms" enctype="multipart/form-data" onsubmit="return checkform();">
        <div class="row-fluid">
            <div class="span9">
                <table class="table table-bordered">
                    <tr>
                        <th>标题 <span class="form-required">*</span></th>
                        <td>
                            <input type="text" name="title" class="require" id="title" value="{$item.title}" style="width: 400px" placeholder="请输入标题">
                        </td>
                    </tr>

                    <tr>
                        <th>性别 <span class="form-required">*</span></th>
                        <td>
                            <label class="radio inline" for="lightup_true"> <input type="radio"   class="radio" name="lightup" value="1" />男</label> &nbsp;&nbsp;&nbsp;<label class="radio inline" for="lightup_true"> <input type="radio"   class="radio" name="lightup" value="2" />女</label> &nbsp;&nbsp;&nbsp;
                        </td>
                    </tr>

                    <tr>
                        <th><b>图片 <span class="form-required">*</span></b></th>

                        <td>
                            <input type="hidden" class="require" name="picture" id="picture" value="{$item.picture}">
                            <div style="text-align: left;">

                                <a href="javascript:upload_one_image('图片上传','#picture');">
                                    <if condition="empty($item['picture'])">
                                        <img src="__TMPL__Public/assets/images/default-thumbnail.png" id="picture-preview" width="135" style="cursor: hand"/>
                                        <else />
                                        <img src="{:sp_get_image_preview_url($item['picture'])}" id="picture-preview" width="135" style="cursor: hand"/>
                                    </if>
                                </a>
                                <input type="button" class="btn btn-small" onclick="$('#picture-previeww').attr('src','__TMPL__Public/assets/images/default-thumbnail.png');$('#picture').val('');return false;" value="取消图片">
                            </div>
                        </td>
                    </tr>

                    <tr>
                        <th>内容</th>
                        <td>
                            <textarea name="content" id="content"  class="require">{$item.content}</textarea>
                        </td>
                    </tr>
                    <tr>
                        <th>编辑器内容 <span class="form-required">*</span></th>
                        <td>
                            <script type="text/plain" id="editor" name="editor">{$item.editor}</script>
                        </td>
                    </tr>
                    <script type="text/javascript">
                        //编辑器路径定义
                        var editorURL = GV.WEB_ROOT;
                    </script>
                    <script type="text/javascript" src="__PUBLIC__/js/ueditor/ueditor.config.js"></script>
                    <script type="text/javascript" src="__PUBLIC__/js/ueditor/ueditor.all.min.js"></script>
                    <script type="text/javascript">
                        $(function() {
                            /////---------------------
                            Wind.use('validate', 'ajaxForm', 'artDialog', function() {
                                //javascript

                                //编辑器
                                editorcontent = new baidu.editor.ui.Editor();
                                editorcontent.render('editor');
                                try {
                                    editorcontent.sync();
                                } catch (err) {
                                }
                                //增加编辑器验证规则
                                jQuery.validator.addMethod('editorcontent', function() {
                                    try {
                                        editorcontent.sync();
                                    } catch (err) {
                                    }
                                    return editorcontent.hasContents();
                                });
                                var form = $('form.js-ajax-forms');
                                //ie处理placeholder提交问题
                                if ($.browser && $.browser.msie) {
                                    form.find('[placeholder]').each(function() {
                                        var input = $(this);
                                        if (input.val() == input.attr('placeholder')) {
                                            input.val('');
                                        }
                                    });
                                }

                            });
                            ////-------------------------
                        });
                    </script>                </table>
            </div>
        </div>
        <div class="form-actions">
            <input type="hidden" name="id" value="{$item.id}"/>
            <button class="btn btn-primary js-ajax-submit" type="submit">提交</button>
            <a class="btn" href="{:U('Index/index')}">返回</a>
        </div>
    </form>
</div>
<script type="text/javascript" src="__PUBLIC__/js/common.js"></script>
</body>
</html>